<?php
/**
 * Created by PhpStorm.
 * User: JunHui.Li
 * Date: 15-2-5
 * Time: 下午2:12
 */

quanli_require('module/base/production/printCode.class.php');
class ajax_productPrintCode{

    public function execute() {

        if (isset($_REQUEST['operFlg']) && $_REQUEST['operFlg'] > 0) {

            switch($_REQUEST['operFlg']) {
                case 1:
                    $this->productionList();
                    break;
                default:
                    $this->toReturn('参数错误');
                    break;

            }

        } else {

            $this->toReturn('参数错误');

        }

    }

    /**
     * 返回数据公共方法
     * @param string $message 提示信息
     * @param int $code 代码
     * @param mixed $data 其他数据
     */
    private function toReturn( $message, $code = 400, $data = null) {

        if (is_null($data)) {
            die( json_encode( array( 'code' => $code, 'message' => $message ) ) );
        } else {
            die( json_encode( array( 'code' => $code, 'message' => $message, 'data' => $data ) ) );
        }

    }

    public function productionList(){
        $sysSearch = new printCode();
        $sys_info_array = $sysSearch->getCodeList( $_REQUEST );

        //组织返回的数据
        $result_array = array(
            'page' => $_REQUEST['page'],
            'total' => $_REQUEST['count'],
            'rows' => array()
        );

        if ($sys_info_array) {
            foreach($sys_info_array as $item) {
                $result_array['rows'][] = array(
                    'id' => $item['bill_no'],
                    'cell'=> array(
                        "<input type='checkbox' id='Checked_".$item['bill_code']."' name='check_id' />", //操作
                        $item['bill_code'], //订单号
                        $item['send_date'] //下单时间
                    )
                );
            }
        }

        echo json_encode($result_array);

    }

}